<!-- 授权管理页面   12.15  wcf全文添加--------------------------- -->
<template>
	<div class="all">

		<span class="title">密码复杂度设置</span>
		<div class="content">
			<div class="items">
				<el-tabs type="border-card" style="width: 100%;">
					<el-tab-pane label="密码复杂度设置">
						<el-form label-position="top" label-width="80px" :model="info2">
							<el-form-item label="启用账号密码复杂度验证" style="display: flex;">
								<el-switch style="margin-left: 20px;" @change="subpswComplexity"
									:disabled="$permissions.indexOf(293)  == -1" v-model="info2.pswComplexity==1"
									active-color="#13ce66" inactive-color="#ff4949">
								</el-switch>
							</el-form-item>
							<el-form-item label="需包含数字" style="display: flex;">
								<el-switch style="margin-left: 20px;" @change="subnumber" v-model="info2.number==1"
									:disabled="$permissions.indexOf(293)  == -1" active-color="#13ce66"
									inactive-color="#ff4949">
								</el-switch>
							</el-form-item>
							<el-form-item label="需包含字母" style="display: flex;">
								<el-switch style="margin-left: 20px;" @change="subchar" v-model="info2.char==1"
									:disabled="$permissions.indexOf(293)  == -1" active-color="#13ce66"
									inactive-color="#ff4949">
								</el-switch>
							</el-form-item>
							<el-form-item label="需包含特殊字符" style="display: flex;">
								<el-switch style="margin-left: 20px;" @change="subspecialchar"
									v-model="info2.specialchar==1" :disabled="$permissions.indexOf(293)  == -1"
									active-color="#13ce66" inactive-color="#ff4949">
								</el-switch>
							</el-form-item>
							<el-form-item label="需包含字母大小写" style="display: flex;">
								<el-switch style="margin-left: 20px;" @change="subaddspecialchar"
									v-model="info2.addspecialchar==1" :disabled="$permissions.indexOf(293)  == -1"
									active-color="#13ce66" inactive-color="#ff4949">
								</el-switch>
							</el-form-item>
							<el-form-item label="密码长度" style="display: flex;">
								<el-input style="margin-left: 20px;" type="number"
									:readonly="$permissions.indexOf(293)  == -1" placeholder="请输入数字"
									v-model="info2.lengths">
									<template slot="append">位</template>
								</el-input>
							</el-form-item>

							<el-form-item>
								<el-button type="primary" @click="sublengths">提交</el-button>
							</el-form-item>
						</el-form>
					</el-tab-pane>

				</el-tabs>
			</div>
		</div>

	</div>
</template>
<script type="text/babel">


	export default {
		
		data() {
			return {
				info2: {
					pswComplexity: '',
					number: '',
					char: '',
					specialchar: '',
					lengths: '',
				},
			};
		},
		components: {},

		created() {},

		mounted() {	
			this.pswComplexity();
			// this.getfail();
			this.getnumber();
			this.getchar();
			this.getspecialchar();
			this.getaddspecialchar();
			this.getlengths();
		},
		methods: {
			// 密码是否需要包含特殊字符
			getaddspecialchar() {
				var that = this
				this.$http.get(this.$url + '/sys/set/pswComplexity/bigandsmall/select')
					.then(function(response) {
			
						that.info2.addspecialchar = response.data.msg
						that.$forceUpdate()
					})
					.catch(function(error) {
						console.log(error);
						// that.$message('网络拥堵，请重新尝试！');
					});
			},
			subaddspecialchar(e) {
				var that = this
				var param = {
						value: e ? 1 : 0
					}
				this.$http.post(this.$url + '/sys/set/pswComplexity/bigandsmall/update', this.$qs.stringify(param))
					.then(function(response) {
						if (response.data.code == '1410') {
							that.$Toast(response.data.msg);
							sessionStorage.setItem('token', '')
							that.$router.push('/login')
							return
						}
			
						that.$Toast(response.data.msg);
						that.getaddspecialchar()
					})
					.catch(function(error) {
						console.log(error);
						that.$message('网络拥堵，请重新尝试！');
					});
			},
			sublengths() {
				if (this.info2.lengths.trim() == '') {
					this.$message('请填写完整！');
					return
				}
				var that = this
				var param = {
						value: this.info2.lengths
					}
				this.$http.post(this.$url + '/sys/set/pswComplexity/length/update', this.$qs.stringify(param))
					.then(function(response) {
						if (response.data.code == '1410') {
							that.$message(response.data.msg);
							sessionStorage.setItem('token', '')
							that.$router.push('/login')
							return
						}
			
						that.$message({
							message: response.data.msg,
							type: 'success'
						});
						that.getlengths()
					})
					.catch(function(error) {
						console.log(error);
						that.$message('网络拥堵，请重新尝试！');
					});
			
			},
			// 查询密码的复杂度检测是否开启
			pswComplexity() {
				var that = this
				this.$http.get(this.$url + '/sys/set/pswComplexity/isOpen')
					.then(function(response) {
			
						that.info2.pswComplexity = response.data.msg
					})
					.catch(function(error) {
						console.log(error);
						// that.$message('网络拥堵，请重新尝试！');
					});
			},
			// 密码是否需要包含数字
			getnumber() {
				var that = this
				this.$http.get(this.$url + '/sys/set/pswComplexity/number/select')
					.then(function(response) {
			
						that.info2.number = response.data.msg
					})
					.catch(function(error) {
						console.log(error);
						// that.$message('网络拥堵，请重新尝试！');
					});
			},
			// 密码是否需要包含字母
			getchar() {
				var that = this
				this.$http.get(this.$url + '/sys/set/pswComplexity/char/select')
					.then(function(response) {
			
						that.info2.char = response.data.msg
					})
					.catch(function(error) {
						console.log(error);
						// that.$message('网络拥堵，请重新尝试！');
					});
			},
			// 密码是否需要包含特殊字符
			getspecialchar() {
				var that = this
				this.$http.get(this.$url + '/sys/set/pswComplexity/specialchar/select')
					.then(function(response) {
			
						that.info2.specialchar = response.data.msg
					})
					.catch(function(error) {
						console.log(error);
						// that.$message('网络拥堵，请重新尝试！');
					});
			},
			//  密码的长度 最少
			getlengths() {
				var that = this
				this.$http.get(this.$url + '/sys/set/pswComplexity/length/select')
					.then(function(response) {
			
						that.info2.lengths = response.data.msg
					})
					.catch(function(error) {
						console.log(error);
						// that.$message('网络拥堵，请重新尝试！');
					});
			},
			subpswComplexity(e) {
				var that = this
				var param = {
						value: e ? 1 : 0
					}
				this.$http.post(this.$url + '/sys/set/pswComplexity/update', this.$qs.stringify(param))
					.then(function(response) {
						if (response.data.code == '1410') {
							that.$message(response.data.msg);
							sessionStorage.setItem('token', '')
							that.$router.push('/login')
							return
						}
			
						that.$message({
							message: response.data.msg,
							type: 'success'
						});
						that.pswComplexity()
					})
					.catch(function(error) {
						console.log(error);
						that.$message('网络拥堵，请重新尝试！');
					});
			},
			subnumber(e) {
				var that = this
				var param = {
						value: e ? 1 : 0
					}
				this.$http.post(this.$url + '/sys/set/pswComplexity/number/update',this.$qs.stringify(param))
					.then(function(response) {
						if (response.data.code == '1410') {
							that.$message(response.data.msg);
							sessionStorage.setItem('token', '')
							that.$router.push('/login')
							return
						}
			
						that.$message({
							message: response.data.msg,
							type: 'success'
						});
						that.getnumber()
					})
					.catch(function(error) {
						console.log(error);
						that.$message('网络拥堵，请重新尝试！');
					});
			},
			subchar(e) {
				console.log(e)
				var that = this
				var param = {
						value: e ? 1 : 0
					}
				this.$http.post(this.$url + '/sys/set/pswComplexity/char/update',this.$qs.stringify(param))
					.then(function(response) {
						if (response.data.code == '1410') {
							that.$message(response.data.msg);
							sessionStorage.setItem('token', '')
							that.$router.push('/login')
							return
						}
			
						that.$message({
							message: response.data.msg,
							type: 'success'
						});
						that.getchar()
					})
					.catch(function(error) {
						console.log(error);
						that.$message('网络拥堵，请重新尝试！');
					});
			},
			subspecialchar(e) {
				var that = this
				var param = {
						value: e ? 1 : 0
					}
				this.$http.post(this.$url + '/sys/set/pswComplexity/specialchar/update', this.$qs.stringify(param))
					.then(function(response) {
						if (response.data.code == '1410') {
							that.$message(response.data.msg);
							sessionStorage.setItem('token', '')
							that.$router.push('/login')
							return
						}
			
						that.$message({
							message: response.data.msg,
							type: 'success'
						});
						that.getspecialchar()
					})
					.catch(function(error) {
						console.log(error);
						that.$message('网络拥堵，请重新尝试！');
					});
			},
		
			},
        }
</script>

<style lang='less' scoped>
	/deep/ input::-webkit-outer-spin-button,
	/deep/ input::-webkit-inner-spin-button {
		-webkit-appearance: none !important;
	}
	
	/deep/ input[type="number"] {
		-moz-appearance: textfield;
	}
	* {
		margin: 0px;
		padding: 0px;
		list-style: none;
		font-family: 微软雅黑 !important;
	}

	.all {
		padding: 10px 30px;
		//background-color: #F3F3F4;
	}

	.title {

		color: #000;
		display: inline-block;
		/* width: 100px; */
		height: 48px;
		line-height: 48px;
		text-align: center;
		border-radius: 5px;
		border-bottom: none;
		font-size: 24px;
	}

	.content {
		width: 100%;
		//border-top:1px solid #DDDDDD ;
	}

	.items {
		max-width: 700px;
		padding: 10px;
		background-color: #fff;
		padding-right: 5%;
	}

	.item {
		margin-top: 20px;
	}

	.items p {
		font-size: 14px;
		color: #333;

	}



	.el-input__inner:hover {
		cursor: pointer;
		background-color: #EEE !important;
		color: #7A6164;
	}

	.el-input__inner:focus {
		outline: none;
	}

	.el-button--primary {
		margin-top: 10px;
		padding: 10px 15px;
	}

	.el-input__inner {
		background-color: #EEE !important;
		color: #717170;
		font-size: 14px;
	}

	.el-input__inner:focus {
		outline: none;
	}
</style>
<style>

</style>
